package io.acna.qiniu.core;

import com.fasterxml.jackson.databind.ObjectMapper;

public class ConvertUtils {

	public static ObjectMapper objectMapper;

	private static String splitLanProperty(String prop) {
		if (prop == null)
			return null;
		String[] lan = prop.split("|");
		if (lan != null && lan.length == 2) {
			prop = lan[0] + " ";
			prop += " " + lan[1];
		}
		return prop;

	}

	public static <T> T readJson(String jsonStr, Class<T> valueType) {
		if (objectMapper == null) {
			objectMapper = new ObjectMapper();
		}

		try {
			return objectMapper.readValue(jsonStr, valueType);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}
}
